/**Nurse Test**/
package edu.gatech.tests;

import java.util.Collection;

import junit.framework.TestCase;
import edu.gatech.userclasses.Nurse;
import edu.gatech.userclasses.Patient;
import edu.gatech.userclasses.User;
import edu.gatech.utilities.Persistence;

/**
 * This class tests the Nurse methods. If the test fails
 * it has to do with the persistence not the tests.
 * @author Will Folsom
 * @version 1.0
 */
public class NurseTest extends TestCase {

	private Nurse nurse;
	private Patient patient;
	
	public NurseTest(){
		User currentUser = null;
		Persistence.load();
		Collection<User> users = Persistence.getUserList();
		for(User u: users){
			if(u.getUserType().equals("Nurse")){
				nurse = (Nurse) u;
			}
		}
	}
	
	/**
	 * 
	 */
	public void testSearchForString(){
		patient = nurse.searchForPatient("Frank");
		assertEquals("Patient not found.", "Frank", patient.getName());
	}
	
	public void testSearchForInt(){
		patient = nurse.searchForPatient("3.14159");
		assertNull("Patient not found.", patient);
	}
	
	public void testSearchForEmptyString(){
		patient = nurse.searchForPatient("");
		assertNull("Patient not found.", patient);
	}
	
	public void testSearchForPassword(){
		patient = nurse.searchForPatient("passwd123");
		assertNull("Patient not found.", patient);
	}
	
	public void testSearchForSQLInjection(){
		patient = nurse.searchForPatient("' or '1'='1");
		assertNull("Patient not found.", patient);
	}
}

